//
//  CAttentionDataView.m
//  HCHK_iphone
//
//  Created by yilong zhang on 12-4-25.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "CAttentionDataView.h"

//==============================================================================================================================

@implementation CPeople

@synthesize m_ID;
@synthesize m_Nick;
@synthesize m_Name;
@synthesize m_Icon;
@synthesize m_IconTask;
@synthesize m_IsLoad;
@synthesize m_Data;
@synthesize m_Email;
@synthesize m_City;
@synthesize m_nType;
@synthesize m_nState;
@synthesize m_lFollowID;
@synthesize m_Date;
@synthesize m_nFrdNum;
@synthesize m_nComNum;
@synthesize m_nPubNum;

-(void)SetValueWithDic:(NSDictionary *)dic
{
    if (dic)
    {
        self.m_ID       = [[dic objectForKey:@"userid"] intValue];
        self.m_Nick     = [dic objectForKey:@"user_nicename"];
        self.m_Name     = [dic objectForKey:@"user_login"];
        self.m_Icon     = [dic objectForKey:@"user_img"];
        self.m_Email    = [dic objectForKey:@"user_email"];
        self.m_City     = [dic objectForKey:@"user_city"];
        self.m_nType    = [[dic objectForKey:@"type"] intValue];
        self.m_lFollowID= [[dic objectForKey:@"followid"] intValue];
        self.m_Date     = [dic objectForKey:@"followTime"];
        self.m_nFrdNum  = [[dic objectForKey:@"CountFriend"] intValue];
        self.m_nComNum  = [[dic objectForKey:@"CountComment"] intValue];
        self.m_nPubNum  = [[dic objectForKey:@"CountArticle"] intValue];
    }
}

-(void)dealloc
{
    self.m_Nick = nil;
    self.m_Name = nil;
    self.m_Icon = nil;
    self.m_Email= nil;
    self.m_City = nil;
    self.m_Date = nil;
    [m_Data release];
    
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_IconTask];
    self.m_IconTask = nil;
    
    [super dealloc];
}

-(NSData*)GetIcon
{
    if (!m_Data)
    {
        m_IsLoad = YES;
        [self DownLoadIcon];
    }
    
    return m_Data;
}

-(void)DownLoadIcon
{
    self.m_IconTask = [[CDownLoadManager DefaultDownLoadManager] AddTask:self.m_Icon Sponsor:self PostData:nil TimeOut:30 Data:[NSNumber numberWithInt:0] MType:PostImage UserInfo:nil];
}

-(void)DidOperationFinished:(COperation *)op Data:(NSData *)data Other:(id)other UserInfo:(id)userinfo
{
    if (0 == [other intValue])
    {
        m_Data = [[NSData alloc] initWithData:data];
    }
    m_IsLoad = NO;
}

-(void)DidOperationError:(COperation *)op Error:(NSError *)error Other:(id)other UserInfo:(id)userinfo
{
    m_IsLoad = NO;
}

-(void)DidOperationTimeOut:(COperation *)op Other:(id)other UserInfo:(id)userinfo
{
    m_IsLoad = NO;
}

@end

//==============================================================================================================================

@implementation CAddress

@synthesize m_Addr;
@synthesize m_Date;
@synthesize m_lFollowid;
@synthesize m_nType;
@synthesize m_LID;
@synthesize m_fLat;
@synthesize m_fLog;
@synthesize m_nState;

-(void)SetValueWithDic:(NSDictionary *)dic
{
    if (dic)
    {
        self.m_Addr     = [dic objectForKey:@"addr"];
        self.m_Date     = [dic objectForKey:@"f_time"];
        self.m_nType    = [[dic objectForKey:@"type"] intValue];
        self.m_lFollowid= [[dic objectForKey:@"followid"] intValue];
        self.m_Date     = [dic objectForKey:@"followTime"];
        self.m_fLat     = [[dic objectForKey:@"x"] floatValue];
        self.m_fLog     = [[dic objectForKey:@"y"] floatValue];
        self.m_nState   = 1;
    }
}

-(void)dealloc
{
    self.m_Addr = nil;
    self.m_Date = nil;
    
    [super dealloc];
}

@end

//==============================================================================================================================

@implementation CAttentionCell

@synthesize delegate;
@synthesize m_EditBtn;
@synthesize m_Data;
@synthesize m_IsValue;

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier Size:(CGSize)size
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        m_IsValue = YES;
        m_EditBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        m_EditBtn.frame = CGRectMake(0, 0, 65, 35);
        m_EditBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        //[m_EditBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [m_EditBtn setTitle:@"取消关注" forState:UIControlStateNormal];
        [m_EditBtn addTarget:self action:@selector(OnButtonDown:) forControlEvents:UIControlEventTouchUpInside];
        
        self.accessoryView = m_EditBtn;
    }
    
    return self;
}

-(void)dealloc
{
    [super dealloc];
}

-(void)OnButtonDown:(UIButton*)sender
{
    [delegate DidAttentionCellButtonClicked:sender Cell:self];
}

@end

//==============================================================================================================================

@implementation CAttentionDataView

@synthesize m_SearchBar;
@synthesize m_Scroll;
@synthesize m_LoadView;
@synthesize m_IsLoading;
@synthesize m_IsPageEnd;
@synthesize m_TableView;
@synthesize m_Cell;
@synthesize m_FootView;
@synthesize m_lUserID;
@synthesize m_Data;
@synthesize m_nOpType;
@synthesize m_Task;
@synthesize m_SearchTask;
@synthesize m_NetCnt;
@synthesize m_SearCnt;
@synthesize m_NoData;
@synthesize m_AddInfo;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0];
        
        //searchbar
        m_SearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 44)];
        m_SearchBar.delegate = self;
        [self addSubview:m_SearchBar];
        [m_SearchBar release];
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, m_SearchBar.frame.size.width, m_SearchBar.frame.size.height)];
        view.backgroundColor = self.backgroundColor;
        [m_SearchBar insertSubview:view atIndex:[[m_SearchBar subviews] count]-1];
        [view release];
        
        //footview
        m_FootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 50)];
        UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        indicator.alpha = 0.0;
        indicator.frame = CGRectMake(0, 0, 25, 25);
        indicator.center= CGPointMake(m_FootView.frame.size.width/2, m_FootView.frame.size.height/2);
        [m_FootView addSubview:indicator];
        [indicator release];
        
        //scrollview
        m_Scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, m_SearchBar.frame.size.height, self.frame.size.width, self.frame.size.height-m_SearchBar.frame.size.height)];
        m_Scroll.backgroundColor = [UIColor clearColor];
        m_Scroll.delegate = self;
        m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, self.frame.size.height-m_SearchBar.frame.size.height+m_FootView.frame.size.height);
        [self addSubview:m_Scroll];
        [m_Scroll release];
        
        //tableview
        m_TableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 0)];
        m_TableView.backgroundColor = [UIColor clearColor];
        m_TableView.scrollEnabled = NO;
        m_TableView.delegate = self;
        m_TableView.dataSource=self;
        [m_Scroll addSubview:m_TableView];
        [m_TableView release];
        
        //footview
        [m_Scroll addSubview:m_FootView];
        [m_FootView release];
        
        //loadview
        [self SetUpLoadView];
        
        //nodata
        m_NoData = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width-140, 40)];
        m_NoData.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
        m_NoData.backgroundColor = [UIColor clearColor];
        m_NoData.font = [UIFont systemFontOfSize:16];
        m_NoData.numberOfLines = 2;
        m_NoData.lineBreakMode = UILineBreakModeWordWrap;
        m_NoData.alpha = 0.0;
        m_NoData.text  = @"嗨!你还没有关注的对象,赶快查找添加吧.";
        [self addSubview:m_NoData];
        [m_NoData release];
        
        m_Data = [[NSMutableArray alloc] init];
        m_lUserID = -1;
        m_nOpType = -1;
        m_IsLoading = NO;
        m_IsPageEnd = NO;
        m_NetCnt = [[CAscCounter alloc] init];
        m_NetCnt.m_nLimit = 6;
        m_NetCnt.m_nOffset= 0;
        m_SearCnt.m_nLimit= 6;
        m_SearCnt.m_nOffset=0;
    }
    return self;
}

-(void)dealloc
{
    [m_Data release];
    [m_SearCnt release];
    [m_NetCnt release];
    
    [super dealloc];
}

//loadview
-(void)SetUpLoadView
{
    m_LoadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
    m_LoadView.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
    m_LoadView.alpha  = 0.0;
    [self addSubview:m_LoadView];
    [m_LoadView release];
    
    UIView *back = [[UIView alloc] initWithFrame:CGRectMake(0, 0, m_LoadView.frame.size.width, m_LoadView.frame.size.height)];
    back.backgroundColor = [UIColor blackColor];
    back.layer.cornerRadius = 5;
    back.alpha = 0.8;
    [m_LoadView addSubview:back];
    [back release];
    
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    indicator.frame = CGRectMake(0, 0, 25, 25);
    indicator.center= CGPointMake(m_LoadView.frame.size.width/2, m_LoadView.frame.size.height/2);
    [m_LoadView addSubview:indicator];
    [indicator release];
}

-(void)ShowLoadView
{
    [[[m_LoadView subviews] objectAtIndex:1] startAnimating];
    m_LoadView.alpha = 1.0;
}

-(void)HiddenLoadView
{
    m_LoadView.alpha = 0.0;
    [[[m_LoadView subviews] objectAtIndex:1] stopAnimating];
}

//footview
-(void)ShowFootView
{
    UIActivityIndicatorView *indicator = [[m_FootView subviews] objectAtIndex:0];
    [indicator startAnimating];
    indicator.alpha = 1.0;
}

-(void)HiddenFootView
{
    UIActivityIndicatorView *indicator = [[m_FootView subviews] objectAtIndex:0];
    indicator.alpha = 0.0;
    [indicator stopAnimating];
}

//datas
-(void)GetDatas:(int)index
{
    //
}

-(void)SetAttentionDatas:(int)index
{
    m_lUserID = [[CUser DefaultUser].U_AID longValue];
    m_IsLoading = YES;
    m_nOpType = index;
    [self ShowLoadView];
    
    //people
    if (0 == m_nOpType)
    {
        [self CommitGetPeopleRequest];
    }
    //food
    else if (1 == m_nOpType)
    {
        [self CommitGetFoodRequest];
    }
    //address
    else if (2 == m_nOpType)
    {
        [self CommitGetAddressRequest];
    }
    else {;}
}

-(void)ClearDatas
{
    m_lUserID = -1;
    m_nOpType = -1;
    [m_Data removeAllObjects];
    
    m_TableView.frame = CGRectMake(m_TableView.frame.origin.x, m_TableView.frame.origin.y, m_TableView.frame.size.width, 0);
    m_FootView.frame  = CGRectMake(m_FootView.frame.origin.x, m_TableView.frame.size.height, m_FootView.frame.size.width, m_FootView.frame.size.height);
    m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, self.frame.size.height-m_SearchBar.frame.size.height+m_FootView.frame.size.height);
    [m_Scroll setContentOffset:CGPointMake(0, 0)];
    
    [m_TableView reloadData];
    m_NetCnt.m_nLimit = 6;
    m_NetCnt.m_nOffset= 0;
    m_SearCnt.m_nLimit= 6;
    m_SearCnt.m_nOffset=0;
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:m_Task];
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_SearchTask = nil;
    self.m_Task = nil;
    m_SearchBar.text = nil;
    m_IsLoading = NO;
    m_IsPageEnd = NO;
    m_Cell      = nil;
    m_NoData.alpha = 0.0;
    [self HiddenLoadView];
    [self HiddenFootView];
}

//searchbar
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    if (2 == m_nOpType)
    {
        [self ShowMap];
    }
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    [m_SearchBar resignFirstResponder];
    
    [self ShowLoadView];
    m_NoData.alpha = 0.0;
    //people
    if (0 == m_nOpType)
    {
        //if (0 == [self SearchPeople:searchBar.text])
        [self CommitAllSearch:m_nOpType Value:searchBar.text];
    }
    //food
    else if (1 == m_nOpType)
    {
        //if (0 == [self SearchFood:searchBar.text])
        [self CommitAllSearch:m_nOpType Value:searchBar.text];
    }
    else {;}
    //[self HiddenLoadView];
}

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar
{
    [m_SearchBar resignFirstResponder];
}

//search
-(int)SearchPeople:(NSString*)value
{
    int nCnt = 0;
    for (CPeople *friend in m_Data)
    {
        if (-1 == m_lUserID)
        {
            return 0;
        }
        else 
        {
            if ([friend.m_Name isEqualToString:value])
            {
                m_Cell.selected = NO;
                NSIndexPath *path = [NSIndexPath indexPathForRow:nCnt inSection:0];
                m_Cell = (CAttentionCell*)[m_TableView cellForRowAtIndexPath:path];
                [m_TableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
                m_Cell.m_Data = friend;
                m_Cell.selected = YES;
                return 1;
            }
            ++nCnt;
        }
    }
    
    return 0;
}

-(int)SearchAddress:(NSString*)value
{
    int nCnt = 0;
    for (CAddress *friend in m_Data)
    {
        if (-1 == m_lUserID)
        {
            return 0;
        }
        else 
        {
            if ([friend.m_Addr isEqualToString:value])
            {
                m_Cell.selected = NO;
                NSIndexPath *path = [NSIndexPath indexPathForRow:nCnt inSection:0];
                m_Cell = (CAttentionCell*)[m_TableView cellForRowAtIndexPath:path];
                [m_TableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
                m_Cell.m_Data = friend;
                m_Cell.selected = YES;
                return 1;
            }
            ++nCnt;
        }
    }
    
    return 0;
}

-(int)SearchFood:(NSString*)value
{
    int nCnt = 0;
    for (CProduct *friend in m_Data)
    {
        if (-1 == m_lUserID)
        {
            return 0;
        }
        else 
        {
            NSLog(@"\r\n\r\n%@\r\n\r\n", friend.P_Name);
            if ([friend.P_Name isEqualToString:value])
            {
                m_Cell.selected = NO;
                NSIndexPath *path = [NSIndexPath indexPathForRow:nCnt inSection:0];
                m_Cell = (CAttentionCell*)[m_TableView cellForRowAtIndexPath:path];
                [m_TableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
                m_Cell.m_Data = friend;
                m_Cell.selected = YES;
                return 1;
            }
            ++nCnt;
        }
    }
    
    return 0;
}

-(void)ShowMap
{
    //保存定位信息
    m_AddInfo = [[CAddrInfo alloc] init];
    m_AddInfo.m_strCity     = [NSString stringWithFormat:@"%@", [CLocator DefaultLocator].m_AddrInfo.m_strCity];
    m_AddInfo.m_strProvince = [NSString stringWithFormat:@"%@", [CLocator DefaultLocator].m_AddrInfo.m_strProvince];
    m_AddInfo.m_strCountry  = [NSString stringWithFormat:@"%@", [CLocator DefaultLocator].m_AddrInfo.m_strCountry];
    m_AddInfo.m_strSum      = [NSString stringWithFormat:@"%@", [CLocator DefaultLocator].m_AddrInfo.m_strSum];
    m_AddInfo.m_fX          = [CLocator DefaultLocator].m_AddrInfo.m_fX;
    m_AddInfo.m_fY          = [CLocator DefaultLocator].m_AddrInfo.m_fY;
    
    CRootCtrlManager *root = [CRootCtrlManager DefaultRootCtrl];
    CCitySelector *citysel = [[CCitySelector alloc] initWithFrame:CGRectMake(0, 0, root.view.frame.size.width, root.view.frame.size.height) ShowGrade:ToStreet];
    citysel.delegate = self;
    [citysel.m_NaviItem setTitle:@"我所在的城市"];
    citysel.m_NaviItem.leftBarButtonItem = nil;
    [root.view addSubview:citysel];
    [citysel release];
    
    [m_SearchBar resignFirstResponder];
}

-(void)HiddenMap
{
    //还原定位信息
    [CLocator DefaultLocator].m_AddrInfo.m_strCity      = [NSString stringWithFormat:@"%@",self.m_AddInfo.m_strCity];
    [CLocator DefaultLocator].m_AddrInfo.m_strProvince  = [NSString stringWithFormat:@"%@",self.m_AddInfo.m_strProvince];
    [CLocator DefaultLocator].m_AddrInfo.m_strCountry   = [NSString stringWithFormat:@"%@",self.m_AddInfo.m_strCountry];
    [CLocator DefaultLocator].m_AddrInfo.m_strSum       = [NSString stringWithFormat:@"%@",self.m_AddInfo.m_strSum];
    [CLocator DefaultLocator].m_AddrInfo.m_fY           = self.m_AddInfo.m_fY;
    [CLocator DefaultLocator].m_AddrInfo.m_fX           = self.m_AddInfo.m_fX;
    [CLocator DefaultLocator].m_Coordinate2D = CLLocationCoordinate2DMake([CLocator DefaultLocator].m_AddrInfo.m_fX, [CLocator DefaultLocator].m_AddrInfo.m_fY);
}

-(void)CommitAllSearch:(int)index Value:(id)value
{
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_Task = nil;
    
    NSMutableString *request = [NSMutableString string];
    NSString        *url     = nil;
    
    //people
    if (0 == index)
    {
        CUser *user = [CUser DefaultUser];
        
        NSLog(@"\r\n\r\n获得%@的好友开始\r\n\r\n", user.U_Name);
        
        NSMutableString *des = [NSMutableString stringWithCapacity:6];
        
        [des appendFormat:@"clientID=%@", [AppConfig DefaultAppConfig].m_strUDID];
        [des appendFormat:@"&mobikey=%@", user.U_Token];
        [des appendFormat:@"&sessionid=%@", user.U_Session];
        [des appendFormat:@"&action=%@", OP_GETMYFRIENDS];
        [des appendFormat:@"&cursor=%d", 0];
        [des appendFormat:@"&offset=%d", 6];
        url = URL_SEARCHFRIEND;
        NSLog(@"\r\n\r\n获得好友请求:%@\r\n\r\n", des);
    }
    //food
    else if (1 == index)
    {
        [request appendFormat:@"cursor=%d", 0];
        [request appendFormat:@"&offset=%d", 6];
        [request appendFormat:@"&action=%@", OP_GETSEARCH_PRODUCT];
        [request appendFormat:@"&value=%@", value];
        [request appendFormat:@"&pic_x=%f", [CLocator DefaultLocator].m_Coordinate2D.latitude];
        [request appendFormat:@"&pic_y=%f", [CLocator DefaultLocator].m_Coordinate2D.longitude];
        url = URL_SEARCH;
    }
    //address
    else if (2 == index)
    {        
        [request appendFormat:@"cursor=%d", 0];
        [request appendFormat:@"&offset=%d", 6];
        [request appendFormat:@"&action=%@", OP_GET_ADDRESS_ATTENTION];
        [request appendFormat:@"&pic_x=%f", [CLocator DefaultLocator].m_Coordinate2D.latitude];
        [request appendFormat:@"&pic_y=%f", [CLocator DefaultLocator].m_Coordinate2D.longitude];
        [request appendFormat:@"&pic_distance=%ld", 1000];
        url = URL_GETNEAREST;
    }
    else {;}
    
    self.m_SearchTask = [[CDownLoadManager DefaultDownLoadManager] AddTask:url Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:5+index]];
}

-(void)ReceiveAllSearchReponse:(NSDictionary*)data Index:(int)index
{
    NSLog(@"\r\n\r\n收到关注查询:%@\r\n\r\n", data);
    //people
    if (0 ==index)
    {
        id rets = [data objectForKey:@"Resource"];
        if ([rets isKindOfClass:[NSArray class]])
        {
            NSMutableArray *results = [NSMutableArray array];
            CFriend *friend = nil;
            
            for (NSDictionary *data in rets)
            {
                friend = [[CFriend alloc] init];
                [friend SetFriendWithDic:data];
                [results addObject:friend];
                [friend release];
            }
            
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_nOpType = index;
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_Condition=m_SearchBar.text;
            [[CUserPageCtrl DefaultUserPage].m_AttentionDetail SetAttentionDetailInfo:results Lat:0 Log:0];
            [[CUserPageCtrl DefaultUserPage] ShowAttentionDetail:nil];
        }
        else 
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
    }
    //food
    else if (1 == index)
    {
        id rets = [data objectForKey:@"Resource"];
        if ([rets isKindOfClass:[NSArray class]])
        {
            NSMutableArray *results = [NSMutableArray array];
            CProduct *product = nil;
            
            for (NSDictionary *sudic in rets)
            {
                product = [[CProduct alloc] init];
                product.m_nState = 1;
                [product SetProductWithDic:sudic Path:[AppConfig DefaultAppConfig].m_DelImagesPath];
                [results addObject:product];
                [product release];
            }
            
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_nOpType = index;
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_Condition=m_SearchBar.text;
            [[CUserPageCtrl DefaultUserPage].m_AttentionDetail SetAttentionDetailInfo:results Lat:0 Log:0];
            [[CUserPageCtrl DefaultUserPage] ShowAttentionDetail:nil];
        }
        else 
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 0.0;
        }
    }
    //address
    else if (2 == index)
    {
        id rets = [data objectForKey:@"Resource"];
        if ([rets isKindOfClass:[NSArray class]])
        {
            NSMutableArray *results = [NSMutableArray array];
            CProduct *product = nil;
            
            for (NSDictionary *sudic in rets)
            {
                product = [[CProduct alloc] init];
                product.m_nState = 1;
                [product SetProductWithDic:sudic Path:[AppConfig DefaultAppConfig].m_DelImagesPath];
                [results addObject:product];
                [product release];
            }
            
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_nOpType = index;
            [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_Condition=m_SearchBar.text;
            [[CUserPageCtrl DefaultUserPage].m_AttentionDetail SetAttentionDetailInfo:results Lat:m_AddInfo.m_fX Log:m_AddInfo.m_fY];
            [[CUserPageCtrl DefaultUserPage] ShowAttentionDetail:nil];
        }
        else 
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        
        [m_AddInfo release];
        m_AddInfo = nil;
    }
    else {;}
}

-(void)DidCitySelectorActived:(int)index Object:(id)object
{
    [self ShowLoadView];
    m_NoData.alpha = 0.0;
    CCitySelector *citysel = object;
    [self HiddenMap];
    
    if ([citysel.m_City.text length] > 6)
    {
        CAddress *addr = [[CAddress alloc] init];
        addr.m_Addr = citysel.m_City.text;
        addr.m_nState = 0;
        [self AddAddress:[NSArray arrayWithObjects:addr, nil]];
        [addr release];
        
        [self CommitAllSearch:m_nOpType Value:citysel.m_City.text];
    }
    else 
    {
        [self HiddenLoadView];
        if (0 == [m_Data count])
            m_NoData.alpha = 1.0;
    }
    [citysel removeFromSuperview];
    //[self HiddenLoadView];
}

//tableview
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70.0;
}

/*
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 50.0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (!m_FootView)
    {
        m_FootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 50)];
        
        UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        indicator.alpha = 0.0;
        indicator.frame = CGRectMake(0, 0, 25, 25);
        indicator.center= CGPointMake(m_FootView.frame.size.width/2, m_FootView.frame.size.height/2);
        [m_FootView addSubview:indicator];
        [indicator release];
    }
    
    return m_FootView;
}
*/
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [m_Data count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [m_SearchBar resignFirstResponder];
    //more
    if ((scrollView.contentOffset.y+scrollView.frame.size.height) - scrollView.contentSize.height > 50 && !m_IsLoading)
    {
        [self ShowFootView];
        m_IsPageEnd = YES;
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //Get more datas
    if (!m_IsLoading && m_IsPageEnd)
    {
        //people
        if (0 == m_nOpType)
        {
            m_IsLoading = YES;
            m_NetCnt.m_nOffset += [m_Data count];
            [self CommitGetPeopleRequest];
        }
        //food
        else if (1 == m_nOpType)
        {
            m_IsLoading = YES;
            m_NetCnt.m_nOffset += [m_Data count];
            [self CommitGetFoodRequest];
        }
        //address
        else if (2 == m_nOpType)
        {
            m_IsLoading = YES;
            m_NetCnt.m_nOffset += [m_Data count];
            [self CommitGetAddressRequest];
        }
        else {;}
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCellStyle style = UITableViewCellStyleDefault;
    if (0 == m_nOpType || 1 == m_nOpType)
    {
        style = UITableViewCellStyleSubtitle;
    }
	CAttentionCell *cell = (CAttentionCell*)[tableView dequeueReusableCellWithIdentifier:@"BaseCell"];
    
    if (!cell)
    {
        cell = [[[CAttentionCell alloc] initWithStyle:style reuseIdentifier:@"BaseCell" Size:CGSizeMake(tableView.frame.size.width, 70)] autorelease];
        cell.textLabel.font = [UIFont systemFontOfSize:12];
        cell.textLabel.numberOfLines = 2;
        cell.detailTextLabel.font = [UIFont systemFontOfSize:11];
        cell.detailTextLabel.numberOfLines = 2;
    }
    
    cell.m_Data = [m_Data objectAtIndex:indexPath.row];
    cell.tag = indexPath.row;
    cell.delegate = self;
    
    //people
    if (0 == m_nOpType)
    {
        CPeople *people = [m_Data objectAtIndex:indexPath.row];
        NSData *data = [people GetIcon];
        if (data)
            cell.imageView.image  = [UIImage imageWithData:data];
        else 
            cell.imageView.image  = [UIImage imageNamed:@"dicon.png"];
        cell.textLabel.text       = people.m_Name;
        cell.detailTextLabel.text = people.m_City;
    }
    //food
    else if (1 == m_nOpType)
    {
        CProduct *product = [m_Data objectAtIndex:indexPath.row];
        NSLog(@"\r\n\r\n图片URL:%@",  product.P_UrlIcon);
        product.m_IconView = cell.imageView;
        NSData *data = [product GetProductIcon];
        if (data)
            cell.imageView.image  = [UIImage imageWithData:data];
        else 
            cell.imageView.image  = [UIImage imageNamed:@"dicon.png"];
        cell.textLabel.text       = product.P_Name;
        cell.detailTextLabel.text = product.P_Position;
    }
    //address
    else if (2 == m_nOpType)
    {
        CAddress *addr = [m_Data objectAtIndex:indexPath.row];
        cell.imageView.image = nil;
        cell.textLabel.text = addr.m_Addr;
        cell.detailTextLabel.text = nil;
    }
    else {;}
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [m_SearchBar resignFirstResponder];
    
    m_Cell.selected = NO;
    m_Cell = (CAttentionCell*)[tableView cellForRowAtIndexPath:indexPath];
    
    //address
    if (2 == m_nOpType)
    {
        [self ShowLoadView];
        [self CommitFoodsInAddressRequest:m_Cell.m_Data];
    }
    //food
    else if (1 == m_nOpType)
    {
        [[CRootCtrlManager DefaultRootCtrl].m_ComEdit SetComEditViewInfoEx:[m_Data objectAtIndex:indexPath.row]];
        [[CRootCtrlManager DefaultRootCtrl].m_ComEdit GetDistance:[m_Data objectAtIndex:indexPath.row] Coordinate:[CLocator DefaultLocator].m_Coordinate2D];
        [[CRootCtrlManager DefaultRootCtrl] ShowComEditView];
    }
}

-(void)DidAttentionCellButtonClicked:(UIButton *)sender Cell:(CAttentionCell*)cell
{
    [self CancelAttention:nil Cell:cell];
}

//cancel attention
-(void)CancelAttention:(id)value Cell:(CAttentionCell*)cell
{
    [self CommitCancelAttention:cell.m_Data];
    [m_Data removeObject:cell.m_Data];
    
    NSIndexPath *path = [NSIndexPath indexPathForRow:cell.tag inSection:0];
    [m_TableView beginUpdates];
    [m_TableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:path, nil] withRowAnimation:YES];
    [m_TableView endUpdates];
    
    m_TableView.frame = CGRectMake(m_TableView.frame.origin.x, m_TableView.frame.origin.y, m_TableView.frame.size.width, m_TableView.frame.size.height-70);
    m_FootView.frame = CGRectMake(m_FootView.frame.origin.x, m_TableView.frame.size.height, m_FootView.frame.size.width, m_FootView.frame.size.height);
    if (m_TableView.frame.size.height > m_Scroll.frame.size.height)
        m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, m_TableView.frame.size.height+m_FootView.frame.size.height);
    
    [m_TableView reloadData];
}

-(void)CommitCancelAttention:(id)value
{
    long ID = 0.0;
    //people
    if (0 == m_nOpType)
    {
        ID = ((CPeople*)value).m_lFollowID;
    }
    //food
    else if (1 == m_nOpType)
    {
        ID = ((CProduct*)value).m_lFollowID;
    }
    //address
    else if (2 == m_nOpType)
    {
        ID = ((CAddress*)value).m_lFollowid;
    }
    else {;}
    
    CUser *user = [CUser DefaultUser];
    NSMutableString *request = [NSMutableString string];
    [request appendFormat:@"action=%@", OP_DELETE_ATTENTION];
    [request appendFormat:@"&type=%d", m_nOpType+1];
    [request appendFormat:@"&mobikey=%@", user.U_Token];
    [request appendFormat:@"&sessionid=%@", user.U_Session];
    [request appendFormat:@"&followid=%ld", ID];
    
    NSLog(@"\r\n\r\n取消关注:%@\r\n\r\n", request);
    
    [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_DELETE_ATTENTION Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:3]];
}

-(void)ReceiveCancelAttentionResponse:(NSDictionary*)data
{
    NSLog(@"\r\n\r\n取消关注结果%@__%@\r\n\r\n", data, [data objectForKey:@"Msg"]);

    if (0 == [[data objectForKey:@"Msg_error"] intValue])
    {
        UIAlertView *suc = [[UIAlertView alloc] initWithTitle:@"提示" message:@"取消关注成功" delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
        [suc show];
        [suc autorelease];
    }
    else 
    {
        UIAlertView *suc = [[UIAlertView alloc] initWithTitle:@"提示" message:@"取消关注失败" delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
        [suc show];
        [suc autorelease];
    }
}

-(void)CommitAddAttention:(int)index Value:(id)value
{
    CUser *user = [CUser DefaultUser];
    NSMutableString *request = [NSMutableString string];
    
    //people
    if (0 == index)
    {
        CPeople *people = value;
        people.m_nState = 1;
        [request appendFormat:@"action=%@", OP_ADD_ATTENTION];
        [request appendFormat:@"&type=%d", 1];
        [request appendFormat:@"&mobikey=%@", user.U_Token];
        [request appendFormat:@"&sessionid=%@", user.U_Session];
        [request appendFormat:@"&value=%ld", people.m_ID];
        
        NSLog(@"\r\n\r\n关注人:%@\r\n\r\n", request);
        
        [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_ATTENTION_PEOPLE Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithInt:0] MType:Post UserInfo:[NSNumber numberWithLong:people.m_ID]];
    }
    //food
    else if (1 == index)
    {
        CProduct *product = value;
        product.m_nState  = 1;
        [request appendFormat:@"action=%@", OP_ADD_ATTENTION];
        [request appendFormat:@"&type=%d", 2];
        [request appendFormat:@"&mobikey=%@", user.U_Token];
        [request appendFormat:@"&sessionid=%@", user.U_Session];
        [request appendFormat:@"&value=%@", product.P_Name];
        
         [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_ATTENTION_FOOD Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithInt:1] MType:Post UserInfo:product.P_AID];
    }
}

-(void)ReceiveAddAttentionReponse:(NSDictionary*)data Type:(int)type
{
    //people
    if (0 == type)
    {
        //
    }
    //food
    else if (1 == type)
    {
        //
    }
}

//add datas
-(void)AddPeople:(NSArray*)datas
{
    [m_Data addObjectsFromArray:datas];
    
    CGFloat fheight = [datas count]*70;
    m_TableView.frame= CGRectMake(m_TableView.frame.origin.x, m_TableView.frame.origin.y, m_TableView.frame.size.width, m_TableView.frame.size.height+fheight);
    m_FootView.frame = CGRectMake(m_FootView.frame.origin.x, m_TableView.frame.size.height, m_FootView.frame.size.width, m_FootView.frame.size.height);
    fheight = m_TableView.frame.size.height+m_FootView.frame.size.height;
    if (fheight > m_Scroll.frame.size.height+m_FootView.frame.size.height)
        m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, m_TableView.frame.size.height+m_FootView.frame.size.height);
    
    [m_TableView reloadData];
}

-(void)AddFood:(NSArray*)datas
{
    [m_Data addObjectsFromArray:datas];
    
    CGFloat fheight = [datas count]*70;
    m_TableView.frame= CGRectMake(m_TableView.frame.origin.x, m_TableView.frame.origin.y, m_TableView.frame.size.width, m_TableView.frame.size.height+fheight);
    m_FootView.frame = CGRectMake(m_FootView.frame.origin.x, m_TableView.frame.size.height, m_FootView.frame.size.width, m_FootView.frame.size.height);
    fheight = m_TableView.frame.size.height+m_FootView.frame.size.height;
    if (fheight > m_Scroll.frame.size.height+m_FootView.frame.size.height)
        m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, m_TableView.frame.size.height+m_FootView.frame.size.height);
    
    [m_TableView reloadData];
}

-(void)AddAddress:(NSArray*)datas
{
    [m_Data addObjectsFromArray:datas];
    
    CGFloat fheight = [datas count]*70;
    m_TableView.frame= CGRectMake(m_TableView.frame.origin.x, m_TableView.frame.origin.y, m_TableView.frame.size.width, m_TableView.frame.size.height+fheight);
    m_FootView.frame = CGRectMake(m_FootView.frame.origin.x, m_TableView.frame.size.height, m_FootView.frame.size.width, m_FootView.frame.size.height);
    fheight = m_TableView.frame.size.height+m_FootView.frame.size.height;
    if (fheight > m_Scroll.frame.size.height+m_FootView.frame.size.height)
        m_Scroll.contentSize = CGSizeMake(m_Scroll.contentSize.width, m_TableView.frame.size.height+m_FootView.frame.size.height);
    
    [m_TableView reloadData];
}

//request
//people
-(void)CommitGetPeopleRequest
{
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_SearchTask = nil;
    
    CUser *user = [CUser DefaultUser];
    NSMutableString *request = [NSMutableString string];
    [request appendFormat:@"action=%@", OP_GET_ATTENTION];
    [request appendFormat:@"&type=%d", 1];
    [request appendFormat:@"&mobikey=%@", user.U_Token];
    [request appendFormat:@"&sessionid=%@", user.U_Session];
    [request appendFormat:@"&offset=%d", m_NetCnt.m_nLimit];
    [request appendFormat:@"&cursor=%d", m_NetCnt.m_nOffset];
    
    NSLog(@"\r\n\r\n提交获得我关注的人:%@\r\n\r\n", request);
    
    self.m_Task = [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_GET_ATTENTION Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:0]];
}

-(void)ReceivePeopleReponse:(NSDictionary *)data
{
    //NSLog(@"\r\n\r\n收到我的关注的人数据:%@__%@\r\n\r\n", data, [data objectForKey:@"Msg_error"]);
       
    id rets = [data objectForKey:@"Resource"];
    if ([rets isKindOfClass:[NSArray class]])
    {
        NSMutableArray *results = [NSMutableArray array];
        CPeople *people = nil;
        
        for (NSDictionary *sudic in rets)
        {
            people = [[CPeople alloc] init];
            people.m_nState = 1;
            [people SetValueWithDic:sudic];
            [results addObject:people];
            [people release];
        }
        
        m_NoData.alpha = 0.0;
        [self AddPeople:results];
    }
    else
    {
        if (0 == [m_Data count])
            m_NoData.alpha = 1.0;
    }
}

//food
-(void)CommitGetFoodRequest
{
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_SearchTask = nil;
    
    CUser *user = [CUser DefaultUser];
    NSMutableString *request = [NSMutableString string];
    [request appendFormat:@"action=%@", OP_GET_ATTENTION];
    [request appendFormat:@"&type=%d", 2];
    [request appendFormat:@"&mobikey=%@", user.U_Token];
    [request appendFormat:@"&sessionid=%@", user.U_Session];
    [request appendFormat:@"&offset=%d", m_NetCnt.m_nLimit];
    [request appendFormat:@"&cursor=%d", m_NetCnt.m_nOffset];
    
    NSLog(@"\r\n\r\n提交获得我关注的美食:%@\r\n\r\n", request);
    
    self.m_Task = [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_GET_ATTENTION Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:1]];
}

-(void)ReceiveFoodResponse:(NSDictionary *)data
{
    //NSLog(@"\r\n\r\n收到我的关注的美食数据:%@__%@", data, [data objectForKey:@"Msg_error"]);
    
    id rets = [data objectForKey:@"Resource"];
    if ([rets isKindOfClass:[NSArray class]])
    {
        NSMutableArray *results = [NSMutableArray array];
        CProduct *product = nil;
        
        for (NSDictionary *sudic in rets)
        {
            product = [[CProduct alloc] init];
            product.m_nState = 1;
            [product SetProductWithDic:sudic Path:[AppConfig DefaultAppConfig].m_DelImagesPath];
            [results addObject:product];
            [product release];
        }
        
        m_NoData.alpha = 0.0;
        [self AddFood:results];
    }
    else
    {
        if (0 == [m_Data count])
            m_NoData.alpha = 1.0;
    }
}

//address
-(void)CommitGetAddressRequest
{
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_SearchTask = nil;
    
    CUser *user = [CUser DefaultUser];
    NSMutableString *request = [NSMutableString string];
    [request appendFormat:@"action=%@", OP_GET_ATTENTION];
    [request appendFormat:@"&type=%d", 3];
    [request appendFormat:@"&mobikey=%@", user.U_Token];
    [request appendFormat:@"&sessionid=%@", user.U_Session];
    [request appendFormat:@"&offset=%d", m_NetCnt.m_nLimit];
    [request appendFormat:@"&cursor=%d", m_NetCnt.m_nOffset];
    
    NSLog(@"\r\n\r\n提交获得我关注的地方:%@\r\n\r\n", request);
    
    self.m_Task = [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_GET_ATTENTION Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:2]];
}

-(void)ReceiveAddressResponse:(NSDictionary *)data
{
    //NSLog(@"\r\n\r\n收到我的关注的地方数据:%@__%@", data, [data objectForKey:@"Msg_error"]);
    
    id rets = [data objectForKey:@"Resource"];
    if ([rets isKindOfClass:[NSArray class]])
    {
        NSMutableArray *results = [NSMutableArray array];
        CAddress *addr = nil;
        
        for (NSDictionary *sudic in rets)
        {
            addr = [[CAddress alloc] init];
            [addr SetValueWithDic:sudic];
            [results addObject:addr];
            [addr release];
        }
        
        m_NoData.alpha = 0.0;
        [self AddAddress:results];
    }
    else
    {
        if (0 == [m_Data count])
            m_NoData.alpha = 1.0;
    }
}

-(void)CommitFoodsInAddressRequest:(CAddress*)addr
{
    [[CDownLoadManager DefaultDownLoadManager] CancelTask:self.m_SearchTask];
    self.m_SearchTask = nil;
    
    NSMutableString *request = [NSMutableString string];
    [request appendFormat:@"action=%@", @"getNear"];
    [request appendFormat:@"&pic_x=%f", addr.m_fLat];
    [request appendFormat:@"&pic_y=%f", addr.m_fLog];
    [request appendFormat:@"&pic_distance=%d", 1000];
    [request appendFormat:@"&offset=%d", m_NetCnt.m_nLimit];
    [request appendFormat:@"&cursor=%d", m_NetCnt.m_nOffset];
    
    NSLog(@"\r\n\r\n提交获得地点1km内美食:%@\r\n\r\n", request);
    
    self.m_Task = [[CDownLoadManager DefaultDownLoadManager] AddTask:URL_GET_ADDRESSATTENTION Sponsor:self PostData:[request dataUsingEncoding:NSUTF8StringEncoding] TimeOut:30 Data:[NSNumber numberWithLong:m_lUserID] MType:Post UserInfo:[NSNumber numberWithInt:4]];
}

-(void)ReceiveFoodsInAddressResponse:(NSDictionary*)data
{
    NSLog(@"\r\n\r\n获得地点1km内美食:%@__%@\r\n\r\n", data, [data objectForKey:@"Msg_error"]);
    
    id rets = [data objectForKey:@"Resource"];
    if ([rets isKindOfClass:[NSArray class]])
    {
        NSMutableArray *results = [NSMutableArray array];
        CProduct *product = nil;
        
        for (NSDictionary *sudic in rets)
        {
            product = [[CProduct alloc] init];
            [product SetProductWithDic:sudic Path:[AppConfig DefaultAppConfig].m_DelImagesPath];
            [results addObject:product];
            [product release];
        }

        CAddress *addr = m_Cell.m_Data;
        [CUserPageCtrl DefaultUserPage].m_AttentionDetail.m_nOpType = 2;
        [[CUserPageCtrl DefaultUserPage].m_AttentionDetail SetAttentionDetailInfo:results Lat:addr.m_fLat Log:addr.m_fLog];
        [[CUserPageCtrl DefaultUserPage] ShowAttentionDetail:nil];
    }
}

//operation
-(void)DidOperationFinished:(COperation *)op Data:(NSData *)data Other:(id)other UserInfo:(id)userinfo
{
    int type = [userinfo intValue];
    NSString      *json = nil;
    NSDictionary  *dic  = nil;
    
    if (m_lUserID == [other longValue])
    {
        json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        dic  = [json JSONValue];
        
        //people
        if (0 == type)
        {
            [self ReceivePeopleReponse:dic];
        }
        //food
        else if (1 == type)
        {
            [self ReceiveFoodResponse:dic];
        }
        //address
        else if (2 == type)
        {
            [self ReceiveAddressResponse:dic];
        }
        //cancel attention
        else if (3 == type)
        {
            [self ReceiveCancelAttentionResponse:dic];
        }
        //foods in address
        else if (4 == type)
        {
            [self ReceiveFoodsInAddressResponse:dic];
        }
        //search
        else if (type > 4 && type < 8)
        {
            [self ReceiveAllSearchReponse:dic Index:type-5];
        }
        else {;}
        
        [json release];
    }
    
    self.m_SearchTask = nil;
    self.m_Task = nil;
    m_IsLoading = NO;
    m_IsPageEnd = NO;
    [self HiddenLoadView];
    [self HiddenFootView];
}

-(void)DidOperationError:(COperation *)op Error:(NSError *)error Other:(id)other UserInfo:(id)userinfo
{
    int type = [userinfo intValue];
    
    if (m_lUserID == [other longValue])
    {
        //people
        if (0 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //food
        else if (1 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //address
        else if (2 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //cancel attention
        else if (3 == type)
        {
            //
        }
        //foods in address
        else if (4 == type)
        {
            //
        }
        //search
        else if (type > 4 && type < 8)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        else {;}
    }
    
    self.m_SearchTask = nil;
    self.m_Task = nil;
    m_IsLoading = NO;
    m_IsPageEnd = NO;
    [self HiddenLoadView];
    [self HiddenFootView];
}

-(void)DidOperationTimeOut:(COperation *)op Other:(id)other UserInfo:(id)userinfo
{
    int type = [userinfo intValue];
    
    if (m_lUserID == [other longValue])
    {
        //people
        if (0 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //food
        else if (1 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //address
        else if (2 == type)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        //cancel attention
        else if (3 == type)
        {
            //
        }
        //foods in address
        else if (4 == type)
        {
            //
        }
        //search
        else if (type > 4 && type < 8)
        {
            if (0 == [m_Data count])
                m_NoData.alpha = 1.0;
        }
        else {;}
    }
    
    self.m_SearchTask = nil;
    self.m_Task = nil;
    m_IsLoading = NO;
    m_IsPageEnd = NO;
    [self HiddenLoadView];
    [self HiddenFootView];
}

@end
